package weiyao.xinxidasai.mapper;


import org.apache.ibatis.annotations.*;
import weiyao.xinxidasai.pojo.Users;


@Mapper
public interface UserMapper {


    @Update("UPDATE users SET `secret_key` = #{secretKey} " +
            "WHERE user_id = #{userId} ")
      int  updateFaceToken(Users user);

    @Insert("INSERT INTO users(username, password) VALUES(#{username}, #{password})")
    @Options(useGeneratedKeys = true, keyProperty = "userId")
    int insertUser(Users user);

    @Select("SELECT * FROM users WHERE username = #{username}")
    Users findByUsername(@Param("username") String username);

    @Select("SELECT COUNT(*) FROM users WHERE username = #{username}")
    int countByUsername(String username);
    @Select("SELECT * FROM users WHERE user_id=#{userId}")
    Users findByUserId(Long userId);

    @Update("UPDATE users SET `password` = #{password} " +
            "WHERE user_id = #{userId} ")
    int  updatepass(@Param("password")String password,@Param("userId")Long userId);

}
